define([], function() {
	return function(id) {
		let content = null;
		let imgs, cs;
		let loadHtml = function(fn = () => {}) {
			if(content == null) {
				$.get(
					"manage/shops/info.html",
					function(data) {
						content = $(data).appendTo("body");
						imgs = content.find(".image-item._imgs");
						cs = content.find(".image-item._cs");
						fn();
					}, "html"
				);
			} else {
				fn();
			}
		}

		let ts = ["外卖", "酒店"];
		let ns = ["审批中", "未通过", "通过"];

		loadHtml(() => {
			content.modal("show");
			$.get(
				"shops/get.do", {
					"id": id
				},
				function(data) {
					if(data.pass){
						content.find("._pass").show();
					}else{
						content.find("._pass").hide();
					}
					data.shops.name = ns[data.shops.shopStatus];
					data.shops.shopsTypeName = ts[data.shops.shopTypeId];
					$.each(data.shops, function(name, value) {
						content.find("[name='" + name + "']").val(value);
						content.find("._" + name).text(value);
					});
					
					
					let timer = window.setInterval(function(){
						try{
							let gis = window.frames.shopsGisShow;
							gis.add(data.shops.shopName, data.shops.point.x, data.shops.point.y, data.shops);
							gis.setCenter(data.shops.point.x, data.shops.point.y);
							window.clearInterval(timer);
						}catch(e){
							console.info(e);
						}
					},500);
					
					
					content.find(":input:not(.close)").attr("disabled", "disabled").css("background-color", "#FFF");

					$.each(data.shops.img, function(i, v) {
						let temp = imgs.clone();
						temp.find("a").attr("href", v + "?download=0");
						temp.find("img").attr("src", v);
						imgs.before(temp);
					});
					imgs.remove();

					$.each(data.shops.certificates, function(i, v) {

						let temp = cs.eq(i);
						temp.find("a").attr("href", v + "?download=0");
						temp.find("img").attr("src", v);

					});

				}, "json"
			);
		});

	}
});